package com.corona.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.corona.Game;

/* compiled from: Action.java */
/* loaded from: pokewilds.jar:com/pkmngen/game/InputProcessor.class */
public class InputProcessor extends Action {
    public Action.Layer layer = Action.Layer.map_5000;
    Vector2 touchLoc = new Vector2();
    boolean gamepadA;
    boolean gamepadB;
    boolean gamepadLeft;
    boolean gamepadRight;
    boolean gamepadUp;
    boolean gamepadDown;
    boolean gamepadStart;
    boolean gamepadL;
    boolean gamepadR;
    float gamepadAxisLeftX;
    float gamepadAxisLeftY;
    float gamepadAxisRightX;
    float gamepadAxisRightY;
    public static int gamepadA1;
    public static int gamepadA2;
    public static int gamepadB1;
    public static int gamepadB2;
    public static boolean acceptInput = true;
    public static boolean upPressed = false;
    public static boolean downPressed = false;
    public static boolean leftPressed = false;
    public static boolean rightPressed = false;
    public static boolean aPressed = false;
    public static boolean bPressed = false;
    public static boolean startPressed = false;
    public static boolean upJustPressed = false;
    public static boolean downJustPressed = false;
    public static boolean leftJustPressed = false;
    public static boolean rightJustPressed = false;
    public static boolean aJustPressed = false;
    public static boolean bJustPressed = false;
    public static boolean startJustPressed = false;
    public static boolean lPressed = false;
    public static boolean lJustPressed = false;
    public static boolean rPressed = false;
    public static boolean rJustPressed = false;
    public static int keyboardA = 54;
    public static int keyboardB = 52;
    public static int keyboardLeft = 21;
    public static int keyboardRight = 22;
    public static int keyboardUp = 19;
    public static int keyboardDown = 20;
    public static int keyboardStart = 66;
    public static int keyboardL = 31;
    public static int keyboardR = 50;
    public static double gamepadMinAxis = 0.3d;

    public InputProcessor() {
        super(new Object[0]);
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        if (acceptInput) {
            if (Gdx.input.isTouched()) {
                float scaleX = 160.0f / game.currScreen.x;
                this.touchLoc.set(((float) Gdx.input.getX()) * scaleX, ((game.currScreen.y - ((float) Gdx.input.getY())) * scaleX) - ((float) ((int) (((game.currScreen.y - (144.0f / scaleX)) / 2.0f) * scaleX))));
            } else {
                this.touchLoc.set(-1.0f, -1.0f);
            }
            this.gamepadR = false;
            this.gamepadL = false;
            this.gamepadStart = false;
            this.gamepadDown = false;
            this.gamepadUp = false;
            this.gamepadRight = false;
            this.gamepadLeft = false;
            this.gamepadB = false;
            this.gamepadA = false;
            if (Game.gamepad != null) {
                if (Game.gamepad.getButton(gamepadA1) || Game.gamepad.getButton(gamepadA2)) {
                    this.gamepadA = true;
                }
                if (Game.gamepad.getButton(gamepadB1) || Game.gamepad.getButton(gamepadB2)) {
                    this.gamepadB = true;
                }
                if (Game.gamepad.getButton(Game.gamepad.getMapping().buttonStart)) {
                    this.gamepadStart = true;
                }
                if (Game.gamepad.getButton(Game.gamepad.getMapping().buttonL1) || Game.gamepad.getButton(Game.gamepad.getMapping().buttonL2)) {
                    this.gamepadL = true;
                }
                if (Game.gamepad.getButton(Game.gamepad.getMapping().buttonR1) || Game.gamepad.getButton(Game.gamepad.getMapping().buttonR2)) {
                    this.gamepadR = true;
                }
                if (Game.gamepad.getButton(Game.gamepad.getMapping().buttonDpadLeft)) {
                    this.gamepadLeft = true;
                }
                if (Game.gamepad.getButton(Game.gamepad.getMapping().buttonDpadRight)) {
                    this.gamepadRight = true;
                }
                if (Game.gamepad.getButton(Game.gamepad.getMapping().buttonDpadUp)) {
                    this.gamepadUp = true;
                }
                if (Game.gamepad.getButton(Game.gamepad.getMapping().buttonDpadDown)) {
                    this.gamepadDown = true;
                }
                this.gamepadAxisLeftX = Game.gamepad.getAxis(Game.gamepad.getMapping().axisLeftX);
                this.gamepadAxisLeftY = Game.gamepad.getAxis(Game.gamepad.getMapping().axisLeftY);
                if (((double) this.gamepadAxisLeftX) > gamepadMinAxis || ((double) this.gamepadAxisLeftX) < (-gamepadMinAxis)) {
                    if (this.gamepadAxisLeftX > 0.0f) {
                        this.gamepadRight = true;
                    } else {
                        this.gamepadLeft = true;
                    }
                }
                if (((double) this.gamepadAxisLeftY) > gamepadMinAxis || ((double) this.gamepadAxisLeftY) < (-gamepadMinAxis)) {
                    if (this.gamepadAxisLeftY > 0.0f) {
                        this.gamepadDown = true;
                    } else {
                        this.gamepadUp = true;
                    }
                }
                this.gamepadAxisRightX = Game.gamepad.getAxis(Game.gamepad.getMapping().axisRightX);
                this.gamepadAxisRightY = Game.gamepad.getAxis(Game.gamepad.getMapping().axisRightY);
                if (((double) this.gamepadAxisRightX) > gamepadMinAxis || ((double) this.gamepadAxisRightX) < (-gamepadMinAxis)) {
                    if (this.gamepadAxisRightX > 0.0f) {
                        this.gamepadRight = true;
                    } else {
                        this.gamepadLeft = true;
                    }
                }
                if (((double) this.gamepadAxisRightY) > gamepadMinAxis || ((double) this.gamepadAxisRightY) < (-gamepadMinAxis)) {
                    if (this.gamepadAxisRightY > 0.0f) {
                        this.gamepadDown = true;
                    } else {
                        this.gamepadUp = true;
                    }
                }
            }
            if (Gdx.input.isKeyPressed(keyboardUp) || this.gamepadUp || DrawMobileControls.upArrowSprite.getBoundingRectangle().contains(this.touchLoc)) {
                upJustPressed = false;
                if (!upPressed) {
                    upJustPressed = true;
                }
                upPressed = true;
            } else {
                upJustPressed = false;
                upPressed = false;
            }
            if (Gdx.input.isKeyPressed(keyboardDown) || this.gamepadDown || DrawMobileControls.downArrowSprite.getBoundingRectangle().contains(this.touchLoc)) {
                downJustPressed = false;
                if (!downPressed) {
                    downJustPressed = true;
                }
                downPressed = true;
            } else {
                downJustPressed = false;
                downPressed = false;
            }
            if (Gdx.input.isKeyPressed(keyboardLeft) || this.gamepadLeft || DrawMobileControls.leftArrowSprite.getBoundingRectangle().contains(this.touchLoc)) {
                leftJustPressed = false;
                if (!leftPressed) {
                    leftJustPressed = true;
                }
                leftPressed = true;
            } else {
                leftJustPressed = false;
                leftPressed = false;
            }
            if (Gdx.input.isKeyPressed(keyboardRight) || this.gamepadRight || DrawMobileControls.rightArrowSprite.getBoundingRectangle().contains(this.touchLoc)) {
                rightJustPressed = false;
                if (!rightPressed) {
                    rightJustPressed = true;
                }
                rightPressed = true;
            } else {
                rightJustPressed = false;
                rightPressed = false;
            }
            if (Gdx.input.isKeyPressed(keyboardA) || this.gamepadA || DrawMobileControls.aSprite.getBoundingRectangle().contains(this.touchLoc)) {
                aJustPressed = false;
                if (!aPressed) {
                    aJustPressed = true;
                }
                aPressed = true;
            } else {
                aJustPressed = false;
                aPressed = false;
            }
            if (Gdx.input.isKeyPressed(keyboardB) || this.gamepadB || DrawMobileControls.bSprite.getBoundingRectangle().contains(this.touchLoc)) {
                bJustPressed = false;
                if (!bPressed) {
                    bJustPressed = true;
                }
                bPressed = true;
            } else {
                bJustPressed = false;
                bPressed = false;
            }
            if (Gdx.input.isKeyPressed(keyboardStart) || this.gamepadStart || DrawMobileControls.startSprite.getBoundingRectangle().contains(this.touchLoc)) {
                startJustPressed = false;
                if (!startPressed) {
                    startJustPressed = true;
                }
                startPressed = true;
            } else {
                startJustPressed = false;
                startPressed = false;
            }
            if (Gdx.input.isKeyPressed(keyboardL) || this.gamepadL) {
                lJustPressed = false;
                if (!lPressed) {
                    lJustPressed = true;
                }
                lPressed = true;
            } else {
                lJustPressed = false;
                lPressed = false;
            }
            if (Gdx.input.isKeyPressed(keyboardR) || this.gamepadR) {
                rJustPressed = false;
                if (!rPressed) {
                    rJustPressed = true;
                }
                rPressed = true;
                return;
            }
            rJustPressed = false;
            rPressed = false;
        }
    }

    @Override // com.corona.game.Action
    public String getCamera() {
        return "map";
    }

    @Override // com.corona.game.Action
    public Action.Layer getLayer() {
        return this.layer;
    }
}
